package com.neusoft.elmboot.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.elmboot.po.CreditTrans;
import com.neusoft.elmboot.service.CreditService;

@RestController
@RequestMapping("/Credits")
public class CreditController {

	@Autowired
	private CreditService creditService;
	
	@PostMapping("/adding/userId/{userId}/eventId/{eventId}/credit/{credit}")
	public int addCredit(CreditTrans creditTrans) {
		return creditService.addCredit(creditTrans);
	}
	
	@GetMapping("/trans/userId/{userId}")
	public List<CreditTrans> getCreditTrans(@PathVariable String userId) {
		return creditService.getCreditTrans(userId);
	}
	
	@GetMapping("/val/userId/{userId}")
	public int getCredit(@PathVariable String userId) {
		return creditService.getCredit(userId);
	}
	
	@GetMapping("/adding/userId/{userId}")
	public List<CreditTrans> getaddingTrans(@PathVariable String userId){
		return creditService.getaddingTrans(userId);
	}
	
	@GetMapping("/using/userId/{userId}")
	public List<CreditTrans> getusingTrans(@PathVariable String userId){
		return creditService.getusingTrans(userId);
	}
	
	@PostMapping("/using/userId/{userId}/eventId/{eventId}/credit/{credit}")
	public int usingCredit(CreditTrans creditTrans) {
		return creditService.usingCredit(creditTrans);
	}
}